package com.biubiu.universaladapter.base.vm

import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.databinding.ViewDataBinding
import com.biubiu.universaladapter.base.vh.BaseDbViewHolder

abstract class DbViewModule<T, DB : ViewDataBinding>(@LayoutRes private val layoutId:Int) : ViewModule<T>(){
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseDbViewHolder<T, DB> {
        return object : BaseDbViewHolder<T, DB>(layoutId, parent) {
            override fun onBindData(data: T, dataPosition: Int, adapterPosition: Int) {
                this@DbViewModule.onBindData(mDataBinding, data, dataPosition, adapterPosition)
            }

            override fun onBindData(data: T, dataPosition: Int, adapterPosition: Int, payloads: List<*>) {
                this@DbViewModule.onBindData(mDataBinding, data, dataPosition, adapterPosition,payloads)
            }
        }
    }

    abstract fun onBindData(dataBinding: DB, data: T, dataPosition: Int, layoutPosition: Int)

   open fun onBindData(dataBinding: DB, data: T, dataPosition: Int, layoutPosition: Int,payloads: List<*>){}
}